In computer science, garbage collection refers to the recovery of pooled computer storage that is being used by a program when that program no longer needs the storage. The garbage collection routine searches memory for data that are no longer active in order to reclaim the space. This frees the storage for use by other programs (or processes within a program). It also ensures that a program using increasing amounts of pooled storage does not reach a quota.
Garbage collection routines are typically encoded when a program is created. In some cases, the routines may even be embedded into hardware or flash memory. Thus, it is increasingly important to verify that the most efficient and accurate garbage collection routines are found before they are implemented, as modification after implementation may be difficult or impossible. Since different programs have different optimal garbage collection routines, it is important to test garbage collection techniques on specific programs before implementation.
Performance analysis of the garbage collection technique during creation or fine-tuning allows the developer to test the efficiency and accuracy of the technique. Typically, the lifetime of the objects is measured by forcing a complete garbage collection after each mutation of the object graph. FIG. 1 is a diagram illustrating an example of an object graph. Roots 100, 102 may point to objects 104, 106. Each time the object graph changes, there is the potential that one or more of the objects may “die”. An object is considered dead if it is no longer reachable from a root. Forcing a garbage collection after each mutation fully updates the system, thus information on when an object dies can easily be recorded.
Additionally, it is often useful to have precise lifetime information in order to analyze the program itself, such as by providing a histogram of the lifetimes of various objects within the program.
However, measuring the lifetime of each object in this manner is fairly processor-intensive. The time it takes to run a garbage collection grows in proportion to the size of the object graph. In order to avoid this overhead, it is typical to only force a garbage collection periodically, for example after every thousand mutations. However, there is significant loss in precision in the lifetime analysis when this periodic measurement is undertaken.
What is needed is a solution for effectively and efficiently computing precise object lifetimes.